package com.keepers.repair.adapter;

import android.graphics.Color;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.keepers.repair.R;
import com.keepers.repair.model.LineAndPlaceModel;
import com.keepers.repair.utils.TimeUtils;

/**
 * auth aboom
 * date 2018/11/17
 */
public class LineAndPointAdapter extends BaseQuickAdapter<LineAndPlaceModel, BaseViewHolder> {

    private String taskName;

    public LineAndPointAdapter(int layoutResId, String taskName) {
        super(layoutResId);
        this.taskName = taskName;
    }

    @Override
    protected void convert(BaseViewHolder helper, LineAndPlaceModel item) {
        if (helper.getAdapterPosition() % 2 == 0) {
            helper.itemView.setBackgroundColor(Color.parseColor("#FFFFFF"));
        } else {
            helper.itemView.setBackgroundColor(Color.parseColor("#F1FEFE"));
        }
        helper.setText(R.id.place_name, item.PlaceName);
        helper.setText(R.id.place_type, item.PlaceType);
        helper.setText(R.id.start_time, TimeUtils.getPlacePatrolTime(item.ShouldTime, item.Normal, item.EarlyPatrol));
        helper.setText(R.id.end_time, TimeUtils.getPlacePatrolTime(item.ShouldTime, item.Normal, item.NightPatrol));
        if ("乱序巡逻".equals(taskName)) {
            helper.setText(R.id.start_time, item.DataTime);
            helper.setText(R.id.end_time, item.OnePointTime);
        }
    }
}
